﻿
@{
    ViewBag.Title = "ConfigOrderExpire";
    Layout = "~/Views/Shared/layoutCommon.cshtml";
}

@section style{
    <style>
        .col-sm-2 {
            width: 20%;
            float: left;
            text-align: right;
            margin-top: 5px;
        }

        .col-sm-3 {
            width: 30%;
            float: left;
        }
    </style>
}
<form id="form1">
    <section class="content-header">
        <h1>
            @ViewBag.CityName 配置业务
            <small></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
            <li><a href="@Url.Content("~/config/CityOpenManage")?provinceid=@ViewBag.ProvinceId">省市业务开通</a></li>
            <li><a href="@Url.Content("~/config/FormBusiness")?cityid=@ViewBag.CityId&provinceid=@ViewBag.ProvinceId&cityname=@ViewBag.CityName">配置业务</a></li>
            <li class="active">配置表单</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header">
                        <div class="bs-example">
                            <ul class="nav nav-tabs">
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigForm?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置表单</a></li>
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigPrice?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置价格</a></li>
                                <li role="presentation" class="active"><a href="#">网办订单过期</a></li>
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigGuidance?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置说明</a></li>
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigExpressTemplate?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置快递</a></li>
                                <li role="presentation"><a href="@Url.Content("~/Config/ConfigView?provinceid="+@ViewBag.ProvinceId+"&cityname="+@ViewBag.CityName+"&cgfid="+@ViewBag.CgfId+"")">配置预览</a></li>
                            </ul>
                        </div>

                        <h3>
                            <i class="fa fa-fw fa-arrow-right"></i>@ViewBag.BizTypeName
                        </h3>
                    </div>
                    <!-- /.box-header -->
                    <div class="form-horizontal">
                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="name">过期间隔时间:</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" value="" style="width:300px;" name="txtExpireInterval" maxlength="5" id="txtExpireInterval" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box-footer text-center">
                        <button class="btn btn-primary" type="button" id="btnSave">确 定 </button>
                        <button class="btn" type="button" id="btnCancel">取 消 </button>
                    </div>
                    <!-- /.box-body -->
                    <!-- /.box -->
                </div>
            </div>
        </div>
    </section>
</form>
@section scriptsBottom{
    <script type="text/javascript">
        $(document).ready(function () {
            initFormValidate();
            $("#btnSave").click(function () {
                save();
            });
            $("#btnCancel").click(function () {
                cancel();
            });

            initOrderExpire();
        });

        function initFormValidate() {
            $("#form1").bootstrapValidator({
                submitHandler: function (valiadtor, loginForm, submitButton) {
                    valiadtor.defaultSubmit();
                },
                fields: {
                    txtExpireInterval: {
                        validators: {
                            notEmpty: {
                                message: '过期间隔时间不能为空'
                            },
                            digits: {
                                message: '过期间隔时间只能是数字'
                            }

                        }
                    }
                }
            });
        }

        //保存
        function save()
        {
            var bootstrapValidator = $("#form1").data('bootstrapValidator');
            bootstrapValidator.validate();

            if (bootstrapValidator.isValid()) {

                BMCW.ajax({
                    url: '@Url.Content("~/Config/SaveOrderExpire")',
                    type: "Post",
                    data: {
                        CityID:@ViewBag.CityId,
                        BizTypeId: @ViewBag.BizTypeId,
                        ExpireInterval: $("#txtExpireInterval").val()
                    },
                    success: function (o) {
                        if (o.status == 0&&o.data==true) {
                            BMCW.msg("保存成功",function(){
                                initOrderExpire();
                            });
                        } else {
                            BMCW.alert("保存失败");
                        }
                    }
                })
            }
        }

        //取消，跳回上一页面
        function cancel()
        {
            history.go(-1);
        }

        //初始化数据
        function initOrderExpire()
        {
            BMCW.ajax({
                url: '@Url.Content("~/Config/GetNetWorkOrderExpireInfo")?cityId=@ViewBag.CityId&bizType=@ViewBag.BizTypeId',
                type: "Get",
                success: function (o) {
                    if (o.status == 0) {
                        if (o.data!=null) {
                            $("#txtExpireInterval").val(o.data.ExpireInterval);
                        }
                        
                    }
                }
            });

        }
    </script>
}
